#region Using

using System;
using System.Text.RegularExpressions;
using WSMon.Core.Interfaces;

#endregion

namespace WSMon.Core.Checkers.Web
{
    public class RegexChecker : Checker, IChecker
    {
        private readonly string _input;
        private readonly string _regexPattern;

        private string _logs = string.Empty;

        public RegexChecker(string input, string regexPattern)
        {
            _input = input;
            _regexPattern = regexPattern;
        }

        #region IChecker Members

        public bool CheckOut()
        {
            try
            {
                return Regex.IsMatch(_input, _regexPattern);
            }
            catch (Exception ex)
            {
                _logs = ex.Message;
                return false;
            }
        }

        public string GetLogs()
        {
            return _logs;
        }

        #endregion
    }
}